TOP = .
OBJ = obj
LIBDIR = /usr/lib
V := @
CC := gcc 
AR := ar
#CFLAGS := -I/usr/include/mysql  -L/usr/lib/mysql -lmysqlclient -luuid -g
CFLAGS := `mysql_config --cflags --libs` -lpthread -luuid -g -I./
bin := test
lib := libmydata.so

all: $(TOP)/$(lib)

me: $(TOP)/$(bin)

srcs := 
objs :=
testsrc := $(TOP)/test.c\
    	$(TOP)/testhelp.c

include $(TOP)/mydata/Makefrag
srcs += $(mydata-srcs)
objs += $(mydata-objs)

$(TOP)/$(lib): $(srcs)
	$(V)$(CC) -o $@ $^ -shared -fPIC $(CFLAGS) 
	$(V)cp $@ $(LIBDIR)/$(lib) 
	$(V)echo + $(lib)

$(TOP)/$(bin): $(testsrc) $(TOP)/$(lib) 
	$(V)$(CC) -o $@ $^ $(CFLAGS) -lmydata
	$(V)echo + $(bin)

clean:
	$(V)rm -f $(TOP)/$(lib)
	$(V)rm -f $(LIBDIR)/$(lib)
	$(V)rm -f $(TOP)/$(bin)
	$(V)rm -rf $(TOP)/$(OBJ)
	$(V)rm -f $(TOP)/cscope.*
	$(V)echo - $(lib) $(bin) $(OBJ)

.PHONY: all clean
